from django.contrib import admin
from models import Person, Quote

class PersonAdmin(admin.ModelAdmin):
    list_display = ('name', 'client', 'number_of_quotes',)
    prepopulated_fields = {'slug': ('name',)}

    def number_of_quotes(self, obj):
        return "%s" % (obj.quote_set.count())

class QuoteAdmin(admin.ModelAdmin):
    list_display = ('__unicode__', 'project', 'person_or_not',)
    list_filter = ('person',)

    def person_or_not(self, obj):
        if(obj.person):
            return "%s" % (obj.person)
        # elif(obj.client):
        #     return "%s" % (obj.client)
        else:
            return "[Nobody, apparently]"

admin.site.register(Person, PersonAdmin)
admin.site.register(Quote, QuoteAdmin)
